// /*
//  * @Author: WanYiMing
//  * @Date:2024-07-25-16:04
//  * @Description:
//  */

using Unity.VisualScripting;
using UnityEngine;

namespace Code
{
    public class PlayerCharter:MonoBehaviour
    {
        public float speed = 5;
        private float inputX;
        private float inputY;
        private float stopX, stopY;
        private Animator animator;
        new private Rigidbody2D rigidbody;
        private Vector3 offset;

        // Start is called before the first frame update
        void Start()
        {
            offset = Camera.main.transform.position - transform.position;
            this.AddComponent<Rigidbody2D>();
            rigidbody = GetComponent<Rigidbody2D>();
            // animator = GetComponent<Animator>();
        }

        // Update is called once per frame
        void Update()
        {
            inputX = Input.GetAxisRaw("Horizontal");
            inputY = Input.GetAxisRaw("Vertical");
            Vector2 input = new Vector2(inputX, inputY).normalized;
            rigidbody.velocity = input * speed;

            if(input != Vector2.zero)
            {
                // animator.SetBool("isMoving", true);
                stopX = inputX;
                stopY = inputY;
            }
            else
            {
                // animator.SetBool("isMoving", false);
            }
            // animator.SetFloat("InputX", stopX);
            // animator.SetFloat("InputY", stopY);

            // Camera.main.transform.position = transform.position + offset;
        }
    }
}